import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:marquee/marquee.dart';
import 'package:wallet_utils/base_router_config.dart';
import 'package:wallet_utils/color.dart';
import 'package:wallet_utils/el_refresh.dart';
import 'package:wallet_utils/ht_common_widgets.dart';
import 'package:wallet_utils/login_utils.dart';
import 'package:wallet_utils/report_widget/click_widget.dart';
import 'package:wallet_utils/text_style.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'logic.dart';

class HomePage extends StatefulWidget {
  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
  final logic = Get.put(HomePageLogic());
  final state = Get.find<HomePageLogic>().state;

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Container(
        decoration: const BoxDecoration(
          image: DecorationImage(
            image: AssetImage("assets/home_bg.png"),
            fit: BoxFit.cover,
          ),
        ),
        child: GetBuilder<HomePageLogic>(builder: (logic) {
          return Scaffold(
            backgroundColor: Colors.transparent,
            body: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top + 20.w),
                ),
                Row(
                  children: [
                    Container(
                      margin: EdgeInsets.only(left: 18.w, right: 6.w),
                      child: Text(
                        '放鑫钱包',
                        style: TextStyleUtils.style000000(
                            fontSize: 22.sp, fontWeight: FontWeight.bold),
                      ),
                    ),
                    Container(
                        margin: EdgeInsets.only(top: 5.w),
                        child: Image.asset(
                          'images/icon_home_title.png',
                          width: 106.w,
                          height: 18.w,
                        )),
                    Expanded(
                      child: Container(
                        margin: EdgeInsets.only(right: 18.w),
                        child: Text(
                          state.city,
                          textAlign: TextAlign.right,
                          style: TextStyleUtils.style000000(
                              fontSize: 16.sp, fontWeight: FontWeight.bold),
                        ),
                      ),
                    )
                  ],
                ),
                Expanded(
                  child: elRefresh(
                    height: 50.w,
                    refreshController: state.refreshController,
                    enablePullUp: false,
                    onRefresh: () async {
                      logic.obtainIndexInfoV3(state.city);
                    },
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        //已借款状态
                        Visibility(
                          visible: state.indexStatus == 6 ? true : false,
                          child: Stack(
                            children: [
                              Image.asset(
                                'images/home_repayment_pro.png',
                                fit: BoxFit.cover,
                              ),
                              Container(
                                margin: EdgeInsets.only(top: 35.w, left: 32.w),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Container(
                                        margin: EdgeInsets.only(left: 5.w, bottom: 10.w),
                                        child: Text(
                                          '待还金额',
                                          style: TextStyleUtils.style000000(fontSize: 14.sp),
                                        )),
                                    Row(
                                      children: [
                                        Expanded(
                                          child: Row(
                                            children: [
                                              Text(
                                                '￥',
                                                style: TextStyleUtils.style000000(fontSize: 30.sp),
                                              ),
                                              Text(
                                                state.headLoanAmount ??
                                                    state.defaultProductVO!.loanAmount!,
                                                style: TextStyleUtils.style000000(
                                                    fontSize: 30.sp, fontWeight: FontWeight.bold),
                                              ),
                                            ],
                                          ),
                                        ),
                                        ClickWidget(
                                          onTap: () {
                                            logic.jumpH5Page('我要还款');
                                          },
                                          child: Container(
                                            width: 115.w,
                                            height: 35.w,
                                            alignment: const Alignment(0, 0),
                                            margin: EdgeInsets.only(
                                              right: 32.w,
                                            ),
                                            decoration: BoxDecoration(
                                              color: ColorManager.colorD93C3A,
                                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                                              borderRadius:
                                                  const BorderRadius.all(Radius.circular(25.0)),
                                            ),
                                            child: Text(
                                              '我要还款',
                                              style: TextStyleUtils.styleFFFFFF(
                                                  fontSize: 16.sp, fontWeight: FontWeight.bold),
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        //审核拒绝
                        _auditRefuse(logic),
                        //审核结果无产品
                        _auditNone(logic),
                        _defaultWidget(logic),
                        //tips
                        Visibility(
                          visible: state.isLogin,
                          child: Container(
                            width: double.infinity,
                            height: 30.w,
                            alignment: const Alignment(0, 0),
                            margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 15.w),
                            decoration: const BoxDecoration(
                              color: Colors.white,
                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                              borderRadius: BorderRadius.all(Radius.circular(25.0)),
                            ),
                            child: Row(
                              children: [
                                Padding(
                                  padding: EdgeInsets.only(left: 15.w, right: 5.w),
                                  child: Image.asset(
                                    'images/icon_notify.png',
                                    width: 17.w,
                                    height: 12.w,
                                  ),
                                ),
                                Visibility(
                                  visible: state.noticeMsg == '' ? false : true,
                                  child: SizedBox(
                                    width: 290.w,
                                    height: 30.w,
                                    child: Marquee(
                                      text: '${state.noticeMsg}         ',
                                      style: TextStyleUtils.style999999(fontSize: 12.sp),
                                      velocity: 20.0,
                                    ),
                                  ),
                                ),
                                // SimpleMarqueeField(
                                //   //controller: simpleMarqueeChange, //如果你希望动态改值就建个controller
                                //   milliseconds: 80,
                                //   //间隔
                                //   width: ScreenUtil().setWidth(300),
                                //   height: ScreenUtil().setHeight(30),
                                //   type: Axis.horizontal,
                                //   //垂直方向还是水平方向
                                //   children: <Widget>[
                                //     Text(
                                //       '提示: 平台需要使用您的手机号和验证码进行创建账号',
                                //       style: TextStyleUtils.style999999(fontSize: 12.sp),
                                //     )
                                //   ],
                                // )
                              ],
                            ),
                          ),
                        ),
                        //Banner
                        Visibility(
                          visible: logic.isShowBanner(),
                          child: ClickWidget(
                            onTap: () {
                              logic.jumpH5Page('banner');
                            },
                            child: Container(
                              alignment: Alignment.center,
                              child: HtImage(
                                icon: true,
                                url: state.imgUrl ?? '',
                                width: 343.w,
                                height: 70.w,
                                radius: 2,
                                placeholder: 'images/icon_home_banner.png',
                                errImage: 'images/icon_home_banner.png',
                              ),
                            ),
                          ),
                        ),
                        //热门产品
                        Visibility(
                          visible: state.showProductFlag == 1 ? true : false,
                          child: Container(
                            decoration: const BoxDecoration(
                              color: Colors.white,
                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                              borderRadius: BorderRadius.all(Radius.circular(8.0)),
                            ),
                            margin: EdgeInsets.only(left: 16.w, right: 16.w, top: 20.w),
                            padding:
                                EdgeInsets.only(left: 16.w, right: 16.w, top: 20.w, bottom: 20.w),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Visibility(
                                  visible: state.productList!.isEmpty ? false : true,
                                  child: Text(
                                    '热门产品',
                                    style: TextStyleUtils.style000000(
                                        fontSize: 18.sp, fontWeight: FontWeight.bold),
                                  ),
                                ),
                                SizedBox(height: 15.w),
                                Visibility(
                                  visible: state.productList!.isEmpty ? false : true,
                                  child: ListView.builder(
                                    padding: EdgeInsets.zero,
                                    shrinkWrap: true,
                                    physics: const NeverScrollableScrollPhysics(),
                                    itemCount: state.productList!.isNotEmpty
                                        ? state.productList!.length - 1
                                        : 0,
                                    itemBuilder: (BuildContext context, int index) {
                                      return buildItem(index + 1, context);
                                    },
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                        //借贷步骤
                        Visibility(
                          visible: (state.showProductFlag == 1) ? false : true,
                          child: Container(
                            width: double.infinity,
                            height: 102.w,
                            alignment: const Alignment(0, 0),
                            margin: EdgeInsets.only(
                              left: 16.w,
                              right: 16.w,
                            ),
                            decoration: const BoxDecoration(
                              color: Colors.white,
                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                              borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            ),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Container(
                                    margin: EdgeInsets.only(left: 16.w, top: 10.w, bottom: 13.w),
                                    child: Text(
                                      '借款步骤',
                                      style: TextStyleUtils.style000000(
                                          fontSize: 14.sp, fontWeight: FontWeight.bold),
                                    )),
                                Container(
                                  margin: EdgeInsets.only(left: 16.w, right: 16.w),
                                  child: Row(
                                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                    children: [
                                      buildBorrowMoneyWidget('images/home_step_one.png', '填写资料'),
                                      progressWidget(),
                                      buildBorrowMoneyWidget('images/home_step_two.png', '申请额度'),
                                      progressWidget(),
                                      buildBorrowMoneyWidget('images/home_step_three.png', '额度审核'),
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                        //选择理由
                        Visibility(
                          visible: state.showProductFlag == 1 ? false : true,
                          child: Container(
                            width: double.infinity,
                            height: 196.w,
                            alignment: const Alignment(0, 0),
                            margin:
                                EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w, bottom: 10.w),
                            decoration: const BoxDecoration(
                              color: Colors.white,
                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                              borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            ),
                            child: Column(
                              children: [
                                Container(
                                    margin: EdgeInsets.only(top: 20.w, bottom: 13.w),
                                    child: Text(
                                      '选择我们的理由',
                                      style: TextStyleUtils.style000000(
                                          fontSize: 14.sp, fontWeight: FontWeight.bold),
                                    )),
                                Container(
                                  margin: EdgeInsets.only(left: 16.w, right: 16.w),
                                  child: GridView.builder(
                                    padding: EdgeInsets.zero,
                                    shrinkWrap: true,
                                    physics: const NeverScrollableScrollPhysics(),
                                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                                      crossAxisCount: 2,
                                      mainAxisSpacing: 15.w,
                                      crossAxisSpacing: 15.w,
                                      childAspectRatio: 2.7,
                                    ),
                                    itemCount: state.list.length,
                                    itemBuilder: (BuildContext context, int index) {
                                      return buildInfoItem(index);
                                    },
                                  ),
                                ),
                              ],
                            ),
                          ),
                        ),
                        //底部文案
                        Container(
                          margin: EdgeInsets.only(left: 50.w, right: 50.w, top: 20.w, bottom: 30.w),
                          child: Text(
                            state.loanRemind ?? '',
                            textAlign: TextAlign.center,
                            style: TextStyleUtils.styleC1C1C1(fontSize: 11.sp),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ],
            ),
          );
        }),
      ),
    );
  }

  Widget _auditNone(HomePageLogic logic) {
    return Visibility(
      visible: state.isLogin == true ? !logic.homeHead() : false,
      child: ClickWidget(
        onTap: () {},
        child: Stack(
          children: [
            Image.asset(
              'images/kap.png',
              fit: BoxFit.cover,
            ),
            Container(
              margin: EdgeInsets.only(
                top: 54.w,
              ),
              alignment: Alignment.center,
              child: Column(
                children: [
                  ClickWidget(
                    onTap: () {},
                    child: Container(
                      width: double.infinity,
                      height: 48.w,
                      alignment: const Alignment(0, 0),
                      margin: EdgeInsets.only(right: 45.w, left: 45.w),
                      decoration: BoxDecoration(
                        color: ColorManager.colorFFFFFF.withAlpha(32),
                        //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                        borderRadius: BorderRadius.all(Radius.circular(25.0)),
                        border:
                            Border.all(color: ColorManager.colorFFFFFF.withAlpha(68), width: 1.5.w),
                      ),
                      child: Text(
                        '系统将根据您的审核资质推荐产品',
                        style: TextStyleUtils.styleFFFFFF(
                            fontSize: 16.sp, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 10.w, bottom: 20.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        buildRichText('息费透明'),
                        SizedBox(width: 10.w),
                        buildRichText('灵活借款'),
                        SizedBox(width: 10.w),
                        buildRichText('急速审核')
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _auditRefuse(HomePageLogic logic) {
    return Visibility(
      visible: state.isLogin == true ? logic.homeHead() : false,
      child: ClickWidget(
        onTap: () {},
        child: Stack(
          children: [
            Image.asset(
              'images/home_heade.png',
              fit: BoxFit.cover,
            ),
            Container(
              margin: EdgeInsets.only(
                top: 54.w,
              ),
              alignment: Alignment.center,
              child: Column(
                children: [
                  Container(
                      margin: EdgeInsets.only(left: 5.w, bottom: 10.w),
                      child: Text(
                        state.homeTitle,
                        style: TextStyleUtils.styleFFFFFF(fontSize: 14.sp,fontWeight: FontWeight.normal),
                      )),
                  Text(
                    state.productList!.isEmpty
                        ? state.defaultProductVO!.loanAmount ?? ""
                        : state.headLoanAmount!,
                    style: TextStyleUtils.styleFFFFFF(fontSize: 40.sp, fontWeight: FontWeight.bold),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 10.w, bottom: 20.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Visibility(
                          visible: !logic.isShowStatus(),
                          child: Container(
                            child: Image.asset(
                              'images/home_prompt.png',
                              width: 14.w,
                              height: 14.w,
                            ),
                            margin: EdgeInsets.only(right: 5.w),
                          ),
                        ),
                        Visibility(
                          visible: !logic.isShowStatus(),
                          child: Text(
                            state.homeContent,
                            style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp),
                          ),
                        ),
                        Visibility(
                          visible: logic.isShowStatus(),
                          child: RichText(
                            textAlign: TextAlign.center,
                            text: TextSpan(
                              children: [
                                TextSpan(
                                    text: state.headProductName ?? '',
                                    style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp)),
                                WidgetSpan(
                                  child: Container(
                                    width: 1.w,
                                    height: 15.w,
                                    margin: EdgeInsets.only(left: 5.w, right: 5.w),
                                    color: ColorManager.colorFFFFFF,
                                  ),
                                ),
                                TextSpan(
                                    text: '年利${state.headLoanMinRate!.toInt()}%起',
                                    style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp)),
                                WidgetSpan(
                                  child: Container(
                                    width: 1.w,
                                    height: 15.w,
                                    margin: EdgeInsets.only(left: 5.w, right: 5.w),
                                    color: ColorManager.colorFFFFFF,
                                  ),
                                ),
                                TextSpan(
                                  text: '最长可借${state.headLoanPeriod}期',
                                  style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp),
                                ),
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                  ClickWidget(
                    onTap: () {
                      //身份认证
                      // Get.toNamed(BaseRouterConfig.identityCertification, arguments: {
                      //   'face': logic.dataInfo?.isShowFace,
                      //   'showContacts': logic.showContacts,
                      //   'channelAuthType': logic.dataInfo?.channelAuthType
                      // });
                      // Get.toNamed(BaseRouterConfig.auditRejection);
                      //联系人
                      // Get.toNamed(BaseRouterConfig.contactPerson,
                      //     arguments: {'face': logic.dataInfo?.isShowFace, 'channelAuthType': logic.dataInfo?.channelAuthType});
                      // Get.toNamed(BaseRouterConfig.auditProgress,arguments: {
                      // 'face': 0,
                      // 'showContacts': false,
                      // 'isShowIdCard': state.isShowChannelAuth,
                      // 'channelAuthType': 0
                      // });
                      //  Get.toNamed(BaseRouterConfig.result);
                      //  Get.toNamed(BaseRouterConfig.basicInfo, arguments: {
                      //    'face': 0,
                      //    'showContacts': false,
                      //    'isShowIdCard': state.isShowChannelAuth,
                      //    'channelAuthType': 0,
                      //  });
                      logic.jumpPage();
                    },
                    child: Container(
                      width: double.infinity,
                      height: 48.w,
                      alignment: const Alignment(0, 0),
                      margin: EdgeInsets.only(right: 38.w, left: 38.w),
                      decoration: const BoxDecoration(
                        color: Colors.white,
                        //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                        borderRadius: BorderRadius.all(Radius.circular(25.0)),
                      ),
                      child: Text(
                        state.homeBtn,
                        style: TextStyleUtils.styleD93C3A(
                            fontSize: 18.sp, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            Visibility(
              visible: logic.isShowPro,
              child: Positioned(
                top: 167.w,
                right: 39.w,
                child: Container(
                  margin: EdgeInsets.only(bottom: 5.w, left: 20.w),
                  child: Stack(
                    alignment: Alignment.center,
                    children: [
                      Image.asset(
                        'images/icon_progress.png',
                        width: 63.w,
                        height: 18.w,
                      ),
                      Text(
                        '${logic.badgeCount}%',
                        style: TextStyleUtils.style954600(
                            fontSize: 10.sp, fontWeight: FontWeight.bold),
                      )
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _defaultWidget(HomePageLogic logic) {
    return Visibility(
      visible: state.isLogin == true ? false : true,
      child: ClickWidget(
        onTap: () {},
        child: Stack(
          children: [
            Image.asset(
              'images/home_heade.png',
              fit: BoxFit.cover,
            ),
            Container(
              margin: EdgeInsets.only(
                top: 54.w,
              ),
              alignment: Alignment.center,
              child: Column(
                children: [
                  Container(
                      margin: EdgeInsets.only(left: 5.w, bottom: 10.w),
                      child: Text(
                        '完善资料最高可获得(元)',
                        style: TextStyleUtils.styleFFFFFF(fontSize: 14.sp),
                      )),
                  Text(
                    '200000',
                    style: TextStyleUtils.styleFFFFFF(fontSize: 40.sp, fontWeight: FontWeight.bold),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 10.w, bottom: 20.w),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Visibility(
                          visible: !logic.isShowStatus(),
                          child: Container(
                            child: Image.asset(
                              'images/home_prompt.png',
                              width: 14.w,
                              height: 14.w,
                            ),
                            margin: EdgeInsets.only(right: 5.w),
                          ),
                        ),
                        Text('请登录完善资料', style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp)),
                      ],
                    ),
                  ),
                  ClickWidget(
                    onTap: () {
                      Get.toNamed(BaseRouterConfig.smsPage);
                    },
                    child: Container(
                      width: double.infinity,
                      height: 48.w,
                      alignment: const Alignment(0, 0),
                      margin: EdgeInsets.only(right: 38.w, left: 38.w),
                      decoration: const BoxDecoration(
                        color: Colors.white,
                        //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                        borderRadius: BorderRadius.all(Radius.circular(25.0)),
                      ),
                      child: Text(
                        '立即提现',
                        style: TextStyleUtils.styleD93C3A(
                            fontSize: 18.sp, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            Visibility(
              visible: logic.isShowPro,
              child: Positioned(
                top: 167.w,
                right: 39.w,
                child: Container(
                  margin: EdgeInsets.only(bottom: 5.w, left: 20.w),
                  child: Stack(
                    alignment: Alignment.center,
                    children: [
                      Image.asset(
                        'images/icon_progress.png',
                        width: 63.w,
                        height: 18.w,
                      ),
                      Text(
                        '${logic.badgeCount}%',
                        style: TextStyleUtils.style954600(
                            fontSize: 10.sp, fontWeight: FontWeight.bold),
                      )
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  RichText buildRichText(String title) {
    return RichText(
      textAlign: TextAlign.center,
      text: TextSpan(
        children: [
          WidgetSpan(
            child: Container(
              child: Image.asset(
                'images/home_prompt.png',
                width: 14.w,
                height: 14.w,
              ),
              margin: EdgeInsets.only(right: 5.w),
            ),
          ),
          WidgetSpan(
            child: Text(
              title,
              style: TextStyleUtils.styleFFFFFF(fontSize: 12.sp),
            ),
          ),
        ],
      ),
    );
  }

  Container buildInfoItem(int index) {
    return Container(
      alignment: Alignment.center,
      child: Row(
        children: [
          Image.asset(
            state.list[index].image ?? '',
            width: 40.w,
            height: 40.w,
          ),
          SizedBox(
            width: 8.w,
          ),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                state.list[index].name ?? '',
                style: TextStyleUtils.style000000(fontSize: 15.sp),
              ),
              SizedBox(
                height: 5.w,
              ),
              Text(
                state.list[index].title ?? '',
                style: TextStyleUtils.style999999(fontSize: 12.sp),
              ),
            ],
          )
        ],
      ),
    );
  }

  Container progressWidget() {
    return Container(
      margin: EdgeInsets.only(bottom: 20.w),
      child: Image.asset(
        'images/home_step_point.png',
        width: 30.w,
        height: 15.w,
      ),
    );
  }

  Container buildBorrowMoneyWidget(String image, String title) {
    return Container(
      child: Column(
        children: [
          Image.asset(
            image,
            width: 30.w,
            height: 30.w,
          ),
          Text(
            title,
            style: TextStyleUtils.style6F6F6F(fontSize: 14.sp),
          )
        ],
      ),
    );
  }

  Widget buildItem(int index, BuildContext context) {
    return ClickWidget(
      onTap: () {
        // showGeneralFunction(context);
      },
      child: Stack(
        children: [
          Container(
            width: double.infinity,
            height: 96.w,
            margin: EdgeInsets.only(bottom: 10.w),
            decoration: BoxDecoration(
              color: ColorManager.colorFFF7F2,
              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
              borderRadius: BorderRadius.all(Radius.circular(5.w)),
            ),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                margin: EdgeInsets.only(top: 15.w, left: 10.w),
                child: Row(
                  children: [
                    HtImage(
                        icon: true,
                        url: state.productList![index].logo,
                        width: 18.w,
                        height: 18.w,
                        radius: 2),
                    SizedBox(
                      width: 5.w,
                    ),
                    Text(
                      state.productList![index].productName ?? '',
                      style:
                          TextStyleUtils.style000000(fontSize: 14.sp, fontWeight: FontWeight.bold),
                    ),
                    SizedBox(
                      height: 15.w,
                      child: ListView.builder(
                        shrinkWrap: true,
                        itemCount: state.productList![index].productTagList!.length,
                        scrollDirection: Axis.horizontal,
                        physics: const NeverScrollableScrollPhysics(),
                        itemBuilder: ((context, position) {
                          return Container(
                            height: 15.w,
                            margin: EdgeInsets.only(left: 8.w),
                            padding: EdgeInsets.only(left: 5.w, right: 5.w),
                            decoration: BoxDecoration(
                              color: ColorManager.colorFFECE9,
                              //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                              borderRadius: BorderRadius.all(Radius.circular(2.w)),
                              border: Border.all(color: ColorManager.colorFFECE9, width: 1.w),
                            ),
                            child: Text(
                              state.productList![index].productTagList![position],
                              style: TextStyleUtils.styleFFECE9(fontSize: 9.w),
                            ),
                          );
                        }),
                      ),
                    ),
                  ],
                ),
              ),
              Container(
                width: 200.w,
                child: Row(
                  children: [
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Container(
                            margin: EdgeInsets.only(left: 10.w, top: 11.w),
                            child: Text(
                              state.productList![index].loanAmount ?? '',
                              style: TextStyleUtils.styleF73326(
                                  fontSize: 18.sp, fontWeight: FontWeight.bold),
                              textAlign: TextAlign.left,
                            ),
                          ),
                          Container(
                              margin: EdgeInsets.only(left: 10.w, top: 3.w),
                              child: Text(
                                '最高额度(元)',
                                style: TextStyleUtils.style999999(fontSize: 12.sp),
                              )),
                        ],
                      ),
                    ),
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Container(
                              margin: EdgeInsets.only(left: 10.w, top: 8.w),
                              child: Text(
                                '${(state.productList![index].loanMinRate)?.toInt()}%起',
                                style: TextStyleUtils.style000000(
                                    fontSize: 18.sp, fontWeight: FontWeight.bold),
                              )),
                          Container(
                              margin: EdgeInsets.only(left: 10.w, top: 3.w),
                              child: Text(
                                '年利率(单利)',
                                style: TextStyleUtils.style999999(fontSize: 12.sp),
                              )),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
          Positioned(
            right: 0,
            top: 35.w,
            child: ClickWidget(
              onTap: () {
                logic.homeProductJump(index);
              },
              child: Container(
                width: 80.w,
                height: 35.w,
                alignment: const Alignment(0, 0),
                margin: EdgeInsets.only(
                  right: 15.w,
                ),
                decoration: BoxDecoration(
                  color: ColorManager.colorD93C3A,
                  //设置四周圆角 角度 这里的角度应该为 父Container height 的一半
                  borderRadius: BorderRadius.all(Radius.circular(17.w)),
                ),
                child: Text(
                  '去申请',
                  style: TextStyleUtils.styleFFFFFF(fontSize: 14.sp, fontWeight: FontWeight.bold),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
